﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using DAO;
using DTO;

namespace BUS
{
    public class PhieuGiaCong_BUS
    {
        private static PhieuGiaCong_BUS m_instance = null;

        public static PhieuGiaCong_BUS Instance
        {
            get
            {
                if (m_instance == null)
                    m_instance = new PhieuGiaCong_BUS();
                return m_instance;
            }
        }

        /// <summary>
        ///   lay ma phieu gia cong
        /// </summary>
        /// 

        public string LayMaPhieuGiaCong()
        {
            string result;
            DataTable dt = PhieuGiaCong_DAO.Instance.LayMaPhieuGiaCong();

            DataRowCollection list = dt.Rows;
            if (list.Count==0)
            {
                return "n/a";
            }
            DataRow dr = list[0];
            string _id = (string)dr["MaPhieuGC"];
            result = _id;
            return result;
        }

        /// <summary>
        ///   them phieu gia cong
        /// </summary>
        /// 

        public bool ThemPhieuGiaCong(PhieuGiaCong_DTO _item)
        {
            return PhieuGiaCong_DAO.Instance.ThemPhieuGiaCong(_item.MaPhieuGC, _item.NgayNhanGC, _item.NgayNhanHang, _item.NgayThanhToan, _item.TongTien, _item.MaTho);
        }

    }
}
